package compiler;
/**
 * Represents the Semantic Analyzer
 * @author Zach Sierakowski
 *
 */
public class MySemanticAnalyzer {
	/**
	 * Converts the lol token into the correct html token
	 */
	public void convert(){
		for(int i = 0; i < MyCompiler.parseTree.size(); i++){
			MyCompiler.html += change(MyCompiler.parseTree.get(i));
		}
	}
		
	/**
	 * Helper method that runs through all possible tokens and switches the lol token
	 * with the proper html token if it is found in the possible tokens. Otherwise it returns the lol
	 * token because that means it is just text and does not need to be converted
	 * @param lol
	 * @return htmlToken
	 */
	private String change(String lol){
		for(int i = 0; i < MyCompiler.possibleTokens.size(); i++){
			if(MyCompiler.possibleTokens.get(i).lol.equalsIgnoreCase(lol)){  //return the html tag that replaced the lol tag
				return MyCompiler.possibleTokens.get(i).html;
			}
		}
		//else return the input which should be text
		return  lol;
	}
}
